<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试跨域</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.0/jquery.min.js"></script>
</head>

<body>
    <button class="btn1">get请求</button>
    <button class="btn2">post请求</button>
</body>
<script>
    $('.btn1').click(function () {
        $.ajax({
            url: "http://localhost:8080/api/get",
            data: {
                name: 'zs',
                age: 10
            },
            success: function (suc) {
                console.log(suc);
            }
        })
    })
    $('.btn2').click(function () {
        $.ajax({
            url: "http://localhost:8080/api/post",
            method: 'post',
            data: {
                "name": 'zs',
                "age": 10
            },
            success: function (suc) {
                console.log(suc);
            }
        })
    })
</script>

</html>